package com.nuc.zyt.day05.bio;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.Socket;

/**
 * @ClassName ServerRunnable
 * @Description TODO
 * @Author 耀酱
 * @Date 2023/5/31 8:40
 * @Version 1.0
 */

public class ServerRunnable implements Runnable {
    private Socket socket;

    public ServerRunnable(Socket socket){
        this.socket = socket;
    }

    @Override
    public void run() {
        // 处理通信逻辑
        while (true){
            try {
                InputStream is = socket.getInputStream();
                BufferedReader br = new BufferedReader(new InputStreamReader(is));
                String str;
                if((str = br.readLine()) != null){
                    System.out.println("服务器收到；"+str);
                }

            }catch (Exception e){

            }finally {


            }
        }
    }
}
